package com.xuhf.producerType;

import com.xuhf.config.Config;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

/*
发送同步消息到一个Broker
 */
public class OneWayProducer {

    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer(Config.PRODUCER_GROUP);
        producer.setNamesrvAddr(Config.NAMESRV_ADDR);
        producer.start();
        for (int i = 0; i < 100; i++) {
            Message message = new Message("04-producer-type",
                    "tagA", ("hello RocketMQ " + String.format("%05d", i)).getBytes());
            producer.sendOneway(message);
        }
        producer.shutdown();
    }
}
